﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace PuzzleCoop
{
    class Shot : Skill
    {
        int damage = 1;
        Projectile projectile = null;

        public Shot(Player caster)
            : base(caster)
        {
        }

        public override void Effect(GameTime gameTime)
        {
            if (projectile == null)
            {
                projectile = new Projectile(caster, GameScreenManager.Load<Texture2D>("Images\\projectile"));
                //projectile.spriteSheet = new SpriteSheet(projectile, 3, 100);
                playScreen.gameObjects.Add(projectile);
            }
            if (!projectile.alive) { alive = false; return; }
            if (!projectile.collided) return;

            // se chegou aqui significa aque acabou de colidir
            projectile.alive = false;
            alive = false;
            GameObject target = projectile.target;
            if (target is Character)
            {
                Character charTarget = (target as Character);
                int d = charTarget.TakeDamage(damage);
                if (d > 0) playScreen.effectsManager.Add(new FloatingText(GameScreenManager.game, charTarget.position, d.ToString(), Color.Red));
                //Log.Add(charTarget.name + " tomou " + d + " de dano do Arcane Shot do " + caster.name);
            }
        }
    }
}
